<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>squid故障汇总 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>squid故障汇总</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Squid/">Squid</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;1、COSS will not function without large file support (off_t is 4 bytes long. Please reconsider recompiling squid with –with-large-files</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Bungled squid_webcache.conf 。。。。。。。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;检查是否在编译squid的时候未加入 –with-large-files 选项，如果是，重新加入此选项再编译一次squid</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;2、使用coss缓存格式的时候，squid不断重建cache</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;可能原因为maxfullbufs值过低，去掉maxfullbufs限制，让其值为无限</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3、日志中有类似如下的内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">2007/03/05 14:46:56| Ready to serve requests.</div><div class="line"></div><div class="line">2007/03/05 14:46:59| clientReadRequest: FD 11 (192.168.1.5:34061) Invalid Request</div><div class="line"></div><div class="line"></div><div class="line">Illegal character <span class="keyword">in</span> hostname; underscores are not allowed</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;注释： 无效的字符串，访问地址中不允许下划线。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;解决办法 ：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;squid 2.5 中，编译的时候加入如下参数</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">--<span class="built_in">enable</span>-underscore</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;允许解析的URL中出现下划线，因为默认squid会认为带下划线的URL地址是非法的，并拒绝访问该地址。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;对于 2.6 版本，编译时没有这个参数，这个参数出现在 squid.conf 的配置文档里，说明是这样的：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">allow_underscore New option to allow _ <span class="keyword">in</span> hostnames, replacing the similar build time configure option <span class="keyword">in</span> 2.5 and earlier.</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;具体的在 squid.conf 中的参数，可以在配置文档里搜索一下 allow_underscore，看一下配置文档的具体注释。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;4、squid的cache.log日志中又类似如下的警告：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">WARNING: 100 swapin MD5 mismatches</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这个错误是说squid读入一个缓存文件的时候，存储在接口对应的位置的URL不是squid认为应该存储在那里的数据。这可能是swap.state有错误或文件指到了磁盘上错误的块（文件系统有错误）。停止squid应用，删除swap.state然后启动squid，让它通过读取缓存文件来重建缓存记录，如果重建后仍然出现上面的情况，那应该就是文件系统或磁盘有问题了。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;5、日志中出现下面警告：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div></pre></td><td class="code"><pre><div class="line">Jun 28 11:14:38 localhost squid[27178]: squidaio_queue_request: Syncing pending I/O operations.. (blocking)</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: squidaio_queue_request: Synced</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: storeAufsOpenDone: (2) No such file or directory</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]:         /data/squid/cache_webcache1/00/6B/00006B29</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: storeAufsOpenDone: (2) No such file or directory</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]:         /data/squid/cache_webcache1/00/DC/0000DC36</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: WARNING: 1 swapin MD5 mismatches</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: WARNING: Disk space over <span class="built_in">limit</span>: 18925740 KB &gt; 16777216 KB</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: storeAufsOpenDone: (2) No such file or directory</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]:         /data/squid/cache_webcache2/00/92/0000924F</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: storeAufsOpenDone: (2) No such file or directory</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]:         /data/squid/cache_webcache1/03/6F/00036FB6</div><div class="line"></div><div class="line">Jun 28 11:14:59 localhost squid[27178]: squidaio_queue_request: Async request queue growing uncontrollably!</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;解决方法：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;检查配置文件，cache设置为aufs文件系统格式，将此设置改为ufs，重建cache缓存目录</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;6、运行reconfigure的时候出现squid: ERROR: no running copy</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;原因是找不到pid文件，如果不是使用默认的squid.conf作为squid 的设置文件，在用squid目录下sbin/squid进行重新启动等动作的时候要加上-f的参数制定配置文件，同时检查pid文件是否存在，有时候可能错误地配置了pid文件到不存在的目录，或者将pid文件配置到了应用没有权限写入的目录，导致没有创建pid文件，如果pid文件不存在，可以手工创建该pid，然后获取squid的pid并写人pid文件。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;7、squid在压力大的情况下响应非常慢</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;检查是否文件描述符太小，如果是，调整文件描述符限制，重启squid，检查squid运行的文件描述符，如果为调整后的，则在启动脚本处启动squid的地方加入调整文件描述符的命令，否则除此外还需先调整文件描述符限制然后重新编译安装一次squid</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;8、缓存效率下降，查看日志无报错，netstat -na查看连接有比较多的连接为SYN_RE，且多为同一IP过来的连接</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;优化TCP网络</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">echo</span> 1 &gt; /proc/sys/net/ipv4/tcp_syncookies</div><div class="line"></div><div class="line"><span class="built_in">echo</span> 1 &gt; /proc/sys/net/ipv4/tcp_synack_retries</div><div class="line"></div><div class="line"><span class="built_in">echo</span> 1 &gt; /proc/sys/net/ipv4/tcp_syn_retries</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;9、缓存效率低，网卡输入输出流量差距很小。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;首先查看系统日志有无squid的报错，如果没有再查看dmesg，看看有无丢包，是否网卡问题，如果没有再查看网关</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;使用squid的时候网关问题关系重大，如果网关没有配置正确，将可能导致用户访问不了。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;10、日志报如下错误：squid: Could not determine fully qualified hostname. Please set ‘visible_hostname’</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;检查/etc/hosts文件、/etc/sysconfig/network文件、和hostname命令结果，看看三者是否对应，如果不对应，需要修改为对应，并且/etc/hosts文件中对应的配置还需要有合法域名格式</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/etc/sysconfig/network中的hostname是系统启动时候加载的hostname值，如果此值与/etc/hosts文件中的值不对应并且squid中没有设置visible_hostname选项的话，会导致系统重启后squid不能正常启动。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;11、日志大量报如下错误：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">Apr 29 08:28:56 localhost squid[13851]: httpReadReply: Excess data from <span class="string">"HEAD http://192.168.230.1/"</span></div><div class="line"></div><div class="line">Apr 29 08:28:56 localhost squid[13851]: httpReadReply: Excess data from <span class="string">"HEAD http://192.168.230.1/"</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这表明服务器返回一个超过squid声明的响应对象最大值的返回值。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;它违反了HTTP协议并导致服务器返回被截断。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;12.runcache发现频繁重启后停止服务:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">:./bin/RunCache Running: squid -sY &gt;&gt; /usr/<span class="built_in">local</span>/squid//var/squid.out 2&gt;&amp;1</div><div class="line"></div><div class="line">./bin/RunCache: line 35: 20000 File size <span class="built_in">limit</span> exceededsquid -NsY <span class="variable">$conf</span> &gt;&gt;<span class="variable">$logdir</span>/squid.out 2&gt;&amp;1</div><div class="line"></div><div class="line">./bin/RunCache: line 35: 20177 File size <span class="built_in">limit</span> exceededsquid -NsY <span class="variable">$conf</span> &gt;&gt;<span class="variable">$logdir</span>/squid.out 2&gt;&amp;1</div><div class="line"></div><div class="line">RunCache: EXITING DUE TO REPEATED, FREQUENT FAILURES</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;故障原因: log超过了ext3文件系统最大支持容量2G导致,解决办法:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;每天轮循一次日志0 0 <em> </em> * /usr/local/squid/sbin/squid -k rotate</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;13.报错信息：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">FATAL:  Failed to verify one of the swap directories, Check cache.log</div><div class="line">        <span class="keyword">for</span> details.  Run <span class="string">'squid -z'</span> to create swap directories</div><div class="line">        <span class="keyword">if</span> needed, or <span class="keyword">if</span> running Squid <span class="keyword">for</span> the first time.</div><div class="line">Squid Cache (Version 2.6.STABLE18): Terminated abnormally.</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;未执行squid -z命令需要执行该命令初始化cache目录，假如想观察这个过程 squid -zX</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">Creating Swap Directories</div><div class="line">FATAL: Failed to make swap directory /usr/local/squid/var/cache/00:</div><div class="line">    (13) Permission denied</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;确认/usr/local/squid/var/cache目录的所有组成都可被squid.conf给定的用户ID访问</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">WARNING:squidaio_queue_request: WARNING - Queue congestion</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;IO的队列满了, ,重谝一下源代码,加大IO的队列或换一种IO方式。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;编译时：–enable-async-io=40 （40，少了）</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">helperOpenServers: Starting 5 <span class="string">'dnsserver'</span> processes</div><div class="line">ipcCreate: fork: (12) Cannot allocate memory</div><div class="line">WARNING: Cannot run <span class="string">'/opt/squid/libexec/dnsserver'</span> process.</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;系统内存被耗光，没有内存分配给squid的dns进程</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">FATAL: xcalloc: Unable to allocate 1 blocks of 4108 bytes!</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Squid 开启大内存导致进程内存溢出</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">cache.log</div><div class="line">2009/08/27 20:49:55| HTCP Disabled.</div><div class="line">2009/08/27 20:49:55| sendto FD 17: (1) Operation not permitted</div><div class="line">2009/08/27 20:49:55| ipcCreate: CHILD: hello write <span class="built_in">test</span> failed</div><div class="line">????</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;configure时编译了–enable-icmp参数，去掉即可。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Squid/10. squid故障汇总/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
